package com.mw

class AppMeta {

    def meta = [
            //  jar
            [
                app: "framework-parent",
                lang: "jar",
                git: "https://github.com/mogu1986/framework-parent.git"
            ],
            [
                app: "boot",
                lang: 'boot',
                artifact: 'target/boot.jar',
                namespace: 'devops',
                git: 'git@gitee.com:mmbluex/boot.git'
            ],
            [
                app: "xc-govern-center",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-govern-center/target/xc-govern-center.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-govern-gateway",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-govern-gateway/target/xc-govern-gateway.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-base-filesystem",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-base-filesystem/target/xc-service-base-filesystem.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-learning",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-learning/target/xc-service-learning.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-manage-cms",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-manage-cms/target/xc-service-manage-cms.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-manage-cms-client",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-manage-cms-client/target/xc-service-manage-cms-client.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-manage-course",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-manage-course/target/xc-service-manage-course.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-manage-media",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-manage-media/target/xc-service-manage-media.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-manage-media-processor",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-manage-media-processor/target/xc-service-manage-media-processor.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-manage-order",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-manage-order/target/xc-service-manage-order.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-ucenter",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-ucenter/target/xc-service-ucenter.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "xc-service-ucenter-auth",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'xc-service-ucenter-auth/target/xc-service-ucenter-auth.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "mall-admin",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'mall-admin/target/mall-admin-1.0-SNAPSHOT.jar',
//                git: 'https://github.com/macrozheng/mall.git'
                git: 'git@gitee.com:mmbluex/mall.git'
            ],
            [
                app: "mall-search",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'mall-search/target/mall-search-1.0-SNAPSHOT.jar',
                git: 'git@gitee.com:mmbluex/mall.git'
            ],
            [
                app: "mall-portal",
                namespace: 'devops',
                lang: 'boot',
                artifact: 'mall-portal/target/mall-portal-1.0-SNAPSHOT.jar',
                git: 'git@gitee.com:mmbluex/mall.git'
            ],
            [
                app: "mall-admin-web",
                namespace: 'devops',
                lang: 'npm',
                artifact: 'dist',
                git: 'git@gitee.com:mmbluex/mall-admin-web.git'
            ],
            [
                app: "redis-spring-boot-starter",
                lang: 'jar',
                git: 'https://github.com/mogu1986/redis-spring-boot-starter.git'
            ],
            [
                app: "distribution",
                lang: 'java',
                namespace: 'default',
                artifact: 'distribution-service/target/distribution-service.jar',
                git: 'git@gitee.com:mmbluex/xuecheng-parent.git'
            ],
            [
                app: "devops-core",
                lang: 'boot',
                artifact: 'devops-core/target/devops-core.jar',
                namespace: 'devops',
                git: 'git@gitee.com:mmbluex/devops.git'
            ],
            [
                app: "devops-git",
                lang: 'boot',
                artifact: 'devops-git/target/devops-git.jar',
                namespace: 'devops',
                git: 'git@gitee.com:mmbluex/devops.git'
            ],
            [
                app: "devops-jenkins",
                lang: 'boot',
                artifact: 'devops-jenkins/target/devops-jenkins.jar',
                namespace: 'devops',
                git: 'git@gitee.com:mmbluex/devops.git'
            ],
            //  front
            [
                app: "components",
                lang: 'nodejs',
                artifact: 'dist',
                compile: false,
                git: 'http://gitlab.top.mw/front/components.git'
            ],
            [
                app: "sync-harbor",
                lang: 'sync-harbor'
            ],
            [
                app: "release",
                lang: 'release'
            ]
    ]

    def getMeta(String app) {
        def result = meta.find { value ->

            if (value.app.equals(app)) {
                return value
            }
            return null
        }
        return result
    }

    def getNamespace(String app) {
        def meta = this.getMeta(app)
        if (meta == null) {
            return null
        }
        return meta.get('namespace')
    }

    def getJavaOpts(Map map, String env) {
        def optsMap = map.get('javaOpts')
        def opts = optsMap.get(env)
        map.put('javaOpts', opts)
    }

    def getEnv(String env) {
        if (env.equals("dev")) {
            return "dev"
        }
        return "test"
//        return "release"
    }

    def getStr(String json) {
        def jsonSlpuer = new groovy.json.JsonSlurperClassic()
        def rs = jsonSlpuer.parseText(json)
        return rs
    }

}
